package com.example.demo.datagen;

import com.example.demo.block.ModBlocks;
import com.example.demo.constant.ItemConstant;
import com.example.demo.item.ModItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.data.server.recipe.RecipeJsonProvider;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.item.ItemConvertible;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.util.Identifier;

import java.util.List;
import java.util.function.Consumer;

public class ModRecipesProvider extends FabricRecipeProvider {
    public static final List<ItemConvertible>  RAW_EXAMPLE_ITEM_LIST = List.of(ModItems.RAW_EXAMPLE_ITEM);
    public ModRecipesProvider(FabricDataOutput output) {
        super(output);
    }

    @Override
    public void generate(Consumer<RecipeJsonProvider> consumer) {
        offerReversibleCompactingRecipes(consumer, RecipeCategory.MISC, ModItems.EXAMPLE_ITEM,
                RecipeCategory.BUILDING_BLOCKS, ModBlocks.EXAMPLE_BLOCK);

        offerSmelting(consumer, RAW_EXAMPLE_ITEM_LIST, RecipeCategory.MISC, ModItems.EXAMPLE_ITEM,
                0.7f, 200, ItemConstant.EXAMPLE_NAME);

        offerBlasting(consumer, RAW_EXAMPLE_ITEM_LIST, RecipeCategory.MISC, ModItems.EXAMPLE_ITEM,
                0.7f, 100, ItemConstant.EXAMPLE_NAME);


        ShapedRecipeJsonBuilder.create(RecipeCategory.MISC, ModItems.PROSPPECTOR_ITEM, 3)
                .pattern("AAA")
                .input('A', ModItems.EXAMPLE_ITEM)
                .criterion(hasItem(ModItems.EXAMPLE_ITEM), conditionsFromItem(ModItems.EXAMPLE_ITEM))
                .offerTo(consumer, new Identifier("sugar_from_beetroot"));



    }
}
